#include "sql/operator/aggregate_operator.h"
#include "sql/stmt/select_stmt.h"

RC AggregationOperator::open()
{
  if (children_.size() < 1) {
    LOG_WARN("Aggregation operator must have least 1 child.");
    return RC::INTERNAL;
  }

  auto &child = children_[0];
  RC rc = child->open();
  if (rc != RC::SUCCESS) {
    LOG_WARN("Failed to open child operator: %s", strrc(rc));
    return rc;
  }
  return RC::SUCCESS;
}

RC AggregationOperator::close()
{
  return children_[0]->close();
}

RC AggregationOperator::next()
{
  return children_[0]->next();
}